"""CreateAdminUserTable Migration."""

from masoniteorm.migrations import Migration


class CreateAdminUserTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with self.schema.create("admin_users") as table:
            table.table_comment("管理员表")

            table.increments("id")
            table.string("account", 15, False).comment("账号")
            table.string("password", 255, True).comment("密码")
            table.string('nickname', 32, True).comment('昵称')
            table.string('salt', 8, False).comment('加密盐')
            table.unsigned_integer('admin_role_id', False).default(0).comment('admin_role.id')
            table.tiny_integer('is_lock', 1, False).default(0).comment('锁定')
            table.tiny_integer('is_deleted', 1, False).default(0).comment('删除')

            table.unique("account", 'uni_account')
            table.timestamps()

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("admin_users")
